<template>
  <div class="info">
    <el-dialog title="添加信息" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="年龄" :label-width="formLabelWidth">
          <el-input v-model="form.age" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="姓名" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <!-- <el-button type="primary" @click="confirmEvt">确 定</el-button> -->
        <el-button :plain="true" type="primary" @click="open2">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      index: "",
      formLabelWidth: "120px",
      dialogFormVisible: false,
      form: {
        age: "",
        name: "",
      },
    };
  },
  methods: {
    // confirmEvt() {

    // },
    open2() {
      this.$bus.emit("conEvt", this.form);
      this.$message({
        message: "添加成功",
        type: "success",
      });
      this.dialogFormVisible = false
    },
  },
  mounted() {
    this.$bus.on("addEvt", (res) => {
      this.dialogFormVisible = res;
    });
  },
};
</script>

<style>
</style>